-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Add support for Tron account change #38536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
7d41f60 to
8bc3923
Compare
8bc3923 to
4bc9929
Compare
Builds ready [4bc9929]
UI Startup Metrics (1212 ± 95 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
4bc9929 to
fc1d5c0
Compare
Builds ready [fc1d5c0]
UI Startup Metrics (1258 ± 122 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
fc1d5c0 to
604bdfe
Compare
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Caution MetaMask internal reviewing guidelines:
|
✨ Files requiring CODEOWNER review ✨🔑 @MetaMask/accounts-engineers (2 files, +90 -6)
|
604bdfe to
183e682
Compare
| const tronScope = | ||
| sessionScopes[MultichainNetworks.TRON] || | ||
| sessionScopes[MultichainNetworks.TRON_DEVNET] || | ||
| sessionScopes[MultichainNetworks.TRON_TESTNET]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Non-existent enum values for Tron testnet networks
The code references MultichainNetworks.TRON_DEVNET and MultichainNetworks.TRON_TESTNET, but these enum values don't exist in the MultichainNetworks enum. The actual testnet values are TRON_NILE and TRON_SHASTA. This will cause tronScope to be undefined for any Tron testnet sessions, preventing account change notifications from being sent for testnet connections. Other parts of the same codebase correctly use TRON_SHASTA and TRON_NILE.
| } from '@metamask/seedless-onboarding-controller'; | ||
| import { PRODUCT_TYPES } from '@metamask/subscription-controller'; | ||
| import { isSnapId } from '@metamask/snaps-utils'; | ||
| import { address } from '@solana/addresses'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Unused and misplaced Solana address import
The address function is imported from @solana/addresses but never used in this file. All other occurrences of address in the file are object destructuring from parseCaipAccountId(), not calls to this imported function. This appears to be accidentally committed debug code or a copy-paste error.
| `${this.accountsController.name}:selectedAccountChange`, | ||
| async (account) => { | ||
| if ( | ||
| account.type === TrxAccountType.Eoa && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Tron types used outside conditional compilation guard
The code uses TrxAccountType.Eoa and TrxScope.Mainnet outside any conditional compilation block, but these types are imported within ///: BEGIN:ONLY_INCLUDE_IF(tron) guards (lines 66-69). When the tron feature flag is disabled, these identifiers will be undefined, causing runtime errors when comparing account.type === TrxAccountType.Eoa or calling getAccountsFromSelectedAccountGroup with scopes: [TrxScope.Mainnet]. The new Tron subscription code needs to be wrapped in the same conditional blocks.
Description
Changelog
CHANGELOG entry:
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Adds Tron accountChanged notifications alongside Solana, unifies non‑EVM accountChanged emit, and updates UI/tests to recognize Tron Wallet Adapter; bumps related dependencies.
accountsChangednotifications on permission updates, selected account, and selected account group changes (_notifyTronAccountChange, new subscriptions).notifyNonEVMAccountChangedForCurrentAccount(handles Solana and Tron) and invoke on CAIP connection init.TronAccountChangedNotifications) and includes default EVM+Tron networks.selectedAccountGroupChangenotification tests; extend connect page tests for Tron Wallet Adapter; update mocks for Tron scopes/methods and permissions utilities defaults.@metamask/chain-agnostic-permissionto^1.3.0and@metamask/multichain-api-middlewareto^1.2.5(lockfile updated).Written by Cursor Bugbot for commit 183e682. This will update automatically on new commits. Configure here.